﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Core.ServiceImpl.Repositories.Interface;
using EzDesk.Core.Model;

namespace EzDesk.Core.ServiceImpl.Repositories
{
    public partial class AppFunctionTypeRepository : IAppFunctionTypeRepository
    {
        public FunctionType GetFunctionTypeById(Guid functionTypeId)
        {
            return this.GetById(functionTypeId).ToFunctionType();
        }

        public FunctionCategory GetCategotyTypeById(Guid functionCategoryId)
        {
            return this.GetById(functionCategoryId).ToFunctionCategory();
        }
    }


    public static class AppFunctionTypeExtension
    {
        public static FunctionType ToFunctionType(this AppFunctionType appFunctionType)
        {
            return new FunctionType()
                       {
                           Id = appFunctionType.Id,
                           DisplayText = appFunctionType.DisplayText,
                           IconName = appFunctionType.IconName,
                           IconUrl = appFunctionType.IconUrl,
                           TypeName = appFunctionType.TypeName,
                           Privilege = appFunctionType.Privilege,
                       };
        }

        public static FunctionCategory ToFunctionCategory(this AppFunctionType appFunctionType)
        {
            return new FunctionCategory()
            {
                Id = appFunctionType.Id,
                DisplayText = appFunctionType.DisplayText,
                IconName = appFunctionType.IconName,
                IconUrl = appFunctionType.IconUrl,
                TypeName = appFunctionType.TypeName,
                Privilege = appFunctionType.Privilege,
            };
        }
    }
}
